﻿USE [iKBSystem]
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'ReformatLikeStatement'))
DROP FUNCTION ReformatLikeStatement
GO

CREATE FUNCTION ReformatLikeStatement(
	@Value NVARCHAR(MAX)
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
	IF(@Value IS NOT NULL)
	BEGIN
		SET @Value = RTRIM(LTRIM(@Value));
		SET @Value = REPLACE(@Value,'--','');
		SET @Value = REPLACE(@Value,'''','');
		SET @Value = REPLACE(@Value,'"','');
		SET @Value = REPLACE(@Value,',','');
		SET @Value = REPLACE(@Value,';','');
		SET @Value = REPLACE(@Value,'/','');
		SET @Value = REPLACE(@Value,'\','');
	END

	RETURN @Value;
END
GO
